*** set working directory
cd "C:\Users\bloem023\Dropbox\Research\UMN Research\ICM\JumpStart\Jeff\Replication files"

use "jumpstart_final.dta", clear

*******************************************
********* Regression analysis *************
*******************************************
set matsize 5000

forvalues k = 1(1) 9 {
	rename L0`k'_ L`k'_
}
forvalues i = 1(1) 38 {
	replace L`i'_ = L`i'_ - 1
}
* Academic outcomes
rename L1_ likely_finish_hs
rename L2_ likely_grad_university
rename L3_ likely_good_job
rename L4_ likely_successful
egen std_likely_finish_hs = std(likely_finish_hs)
egen std_likely_grad_university = std(likely_grad_university)
egen std_likely_good_job = std(likely_good_job)
egen std_likely_successful = std(likely_successful)
gen academic_index = (std_likely_finish_hs + std_likely_grad_university + ///
std_likely_good_job + std_likely_successful)/4
egen std_academic_index = std(academic_index)

* Scholastic outcomes
rename L5_ reads_alot
rename L6_ practice_math
rename L7_ succeed_highschl
rename L8_ learning_languages
rename L9_ quite_smart
egen std_reads_alot = std(reads_alot)
egen std_practice_math = std(practice_math)
egen std_succeed_highschl = std(succeed_highschl)
egen std_learning_languages = std(learning_languages)
egen std_quite_smart = std(quite_smart)
gen scholastic_index = (std_reads_alot + std_practice_math + std_succeed_highschl + ///
std_learning_languages + std_quite_smart)/5
egen std_scholastic_index = std(scholastic_index)

* Grit
rename L10_ easily_discouraged
gen neg_easily_discouraged = 4 - easily_discouraged
rename L11_ hard_worker
rename L12_ changes_mind
rename L13_ difficulty_focusing
gen neg_difficulty_focusing = 4 - difficulty_focusing
rename L14_ finish_started
rename L15_ easily_distracted
gen neg_easily_distracted = 4 - easily_distracted
rename L16_ patient
egen std_easily_discouraged = std(easily_discouraged)
egen std_neg_easily_discouraged = std(neg_easily_discouraged)
egen std_hard_worker = std(hard_worker)
egen std_changes_mind = std(changes_mind)
egen std_difficulty_focusing = std(difficulty_focusing)
egen std_neg_difficulty_focusing = std(neg_difficulty_focusing)
egen std_finish_started = std(finish_started)
egen std_easily_distracted = std(easily_distracted)
egen std_neg_easily_distracted = std(neg_easily_distracted)
egen std_patient = std(patient)

* Peer affiliation
rename L17_ easily_make_friend
rename L18_ avoid_social
gen neg_avoid_social = 4 - avoid_social
rename L19_ frequently_fights
rename L20_ comforts_others
rename L21_ often_bullied
gen neg_often_bullied = 4 - often_bullied
egen std_easily_make_friend = std(easily_make_friend)
egen std_avoid_social = std(avoid_social)
egen std_neg_avoid_social = std(neg_avoid_social)
egen std_frequently_fights = std(frequently_fights)
egen std_comforts_others = std(comforts_others)
egen std_often_bullied = std(often_bullied)
egen std_neg_often_bullied = std(neg_often_bullied)

* Behavioral outcomes
rename L22_ often_disobedient
gen neg_often_disobedient = 4 - often_disobedient
rename L23_ acts_younger
rename L24_ kind_to_others
rename L25_ often_breaks_rules
gen neg_often_breaks_rules = 4 - often_breaks_rules
egen std_often_disobedient = std(often_disobedient)
egen std_neg_often_disobedient = std(neg_often_disobedient)
egen std_acts_younger = std(acts_younger)
egen std_kind_to_others = std(kind_to_others)
egen std_often_breaks_rules = std(often_breaks_rules)
egen std_neg_often_breaks_rules = std(neg_often_breaks_rules)

* Spirituality
rename L26_ participates_youthgroup
rename L27_ asks_qs_god
rename L28_ enjoys_church
rename L29_ give_offering
egen std_participates_youthgroup = std(participates_youthgroup)
egen std_asks_qs_god = std(asks_qs_god)
egen std_enjoys_church = std(enjoys_church)
egen std_give_offering = std(give_offering)

* Self-control
rename L30_ easily_mad
rename L31_ waits_to_speak
rename L32_ yells_when_mad
rename L33_ easily_sit_still
rename L34_ makes_decisions_quickly
gen neg_makes_decisions_quickly = 4 - makes_decisions_quickly
egen std_easily_mad = std(easily_mad)
egen std_waits_to_speak = std(waits_to_speak)
egen std_yells_when_mad = std(yells_when_mad)
egen std_easily_sit_still = std(easily_sit_still)
egen std_makes_decisions_quickly = std(makes_decisions_quickly)
egen std_neg_makes_decisions_quickly = std(neg_makes_decisions_quickly)

* Positive identity
rename L35_ easily_upset
rename L36_ less_value
rename L37_ talks_about_future
rename L38_ positive_talk
egen std_easily_upset = std(easily_upset)
egen std_less_value = std(less_value)
egen std_talks_about_future = std(talks_about_future)
egen std_positive_talk = std(positive_talk)


*********** Big 5 Indices *****************

* Openness 
gen openness_index = (std_positive_talk + std_talks_about_future + std_asks_qs_god + std_changes_mind)/4
egen std_openness_index = std(openness_index)

pca positive_talk talks_about_future asks_qs_god changes_mind, comp(1)
predict openness_pca

* Conscientiousness
gen conscientiousness_index = (std_easily_sit_still + std_waits_to_speak + std_patient + ///
std_finish_started + std_neg_easily_distracted + std_neg_difficulty_focusing + std_hard_worker + ///
std_neg_easily_discouraged)/8
egen std_conscientiousness_index = std(conscientiousness_index)

pca easily_sit_still waits_to_speak patient finish_started ///
neg_easily_distracted neg_difficulty_focusing hard_worker neg_easily_discouraged, comp(1)
predict conscientiousness_pca

* Extraversion
gen extraversion_index = (std_give_offering + std_participates_youthgroup + std_neg_avoid_social + ///
easily_make_friend + std_neg_often_bullied)/5
egen std_extraversion_index = std(extraversion_index)

pca give_offering participates_youthgroup neg_avoid_social easily_make_friend ///
neg_often_bullied, comp(1)
predict extraversion_pca

* Agreeableness
gen agreeableness_index = (std_enjoys_church + std_neg_often_breaks_rules + std_kind_to_others + ///
std_neg_often_disobedient + std_comforts_others)/5
egen std_agreeableness_index = std(agreeableness_index)

pca enjoys_church neg_often_breaks_rules kind_to_others neg_often_disobedient ///
comforts_others, comp(1)
predict agreeableness_pca

* Neuroticism
gen neuroticism_index = (std_neg_makes_decisions_quickly + std_less_value + std_easily_upset + ///
std_yells_when_mad + std_easily_mad + std_acts_younger + std_frequently_fights)/7
egen std_neuroticism_index = std(neuroticism_index)

gen neg_less_value = 4 - less_value
egen std_neg_less_value = std(neg_less_value)
gen neg_easily_upset = 4 - easily_upset
egen std_neg_easily_upset = std(neg_easily_upset)
gen neg_yells_when_mad = 4 - yells_when_mad
egen std_neg_yells_when_mad = std(neg_yells_when_mad)
gen neg_easily_mad = 4 - easily_mad
egen std_neg_easily_mad = std(neg_easily_mad)
gen neg_acts_younger = 4 - acts_younger
egen std_neg_acts_younger = std(neg_acts_younger)
gen neg_frequently_fights = 4 - frequently_fights
egen std_neg_frequently_fights = std(neg_frequently_fights)
gen neg_neuroticism_index = (std_makes_decisions_quickly + std_neg_less_value + std_neg_easily_upset + ///
std_neg_yells_when_mad + std_neg_easily_mad + std_neg_acts_younger + std_neg_frequently_fights)/7
egen std_neg_neuroticism_index = std(neg_neuroticism_index)

pca neg_makes_decisions_quickly less_value easily_upset yells_when_mad easily_mad ///
acts_younger frequently_fights, comp(1)
predict neuroticism_pca

pca makes_decisions_quickly neg_less_value neg_easily_upset neg_yells_when_mad neg_easily_mad ///
neg_acts_younger neg_frequently_fights, comp(1)
predict neg_neuroticism_pca

*** validity check ***

* openness 
corr std_positive_talk std_talks_about_future std_asks_qs_god std_changes_mind
* conscientiousness
corr std_easily_sit_still std_waits_to_speak std_patient std_finish_started ///
std_neg_easily_distracted std_neg_difficulty_focusing std_hard_worker std_neg_easily_discouraged
* extraversion
corr std_give_offering std_participates_youthgroup std_neg_avoid_social ///
easily_make_friend std_neg_often_bullied
* agreeableness
corr std_enjoys_church std_neg_often_breaks_rules std_kind_to_others ///
std_neg_often_disobedient std_comforts_others
* Rev(Neuroticism)
corr std_makes_decisions_quickly std_neg_less_value std_neg_easily_upset ///
std_neg_yells_when_mad std_neg_easily_mad std_neg_acts_younger std_neg_frequently_fights
* all
corr std_positive_talk std_talks_about_future std_asks_qs_god std_changes_mind ///
std_easily_sit_still std_waits_to_speak std_patient std_finish_started ///
std_neg_easily_distracted std_neg_difficulty_focusing std_hard_worker ///
std_neg_easily_discouraged std_give_offering std_participates_youthgroup std_neg_avoid_social ///
easily_make_friend std_neg_often_bullied std_enjoys_church std_neg_often_breaks_rules ///
std_kind_to_others std_neg_often_disobedient std_comforts_others std_makes_decisions_quickly ///
std_neg_less_value std_neg_easily_upset std_neg_yells_when_mad std_neg_easily_mad ///
std_neg_acts_younger std_neg_frequently_fights


***************************** Regression analysis ******************************

* Openness
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A7
reg std_openness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Appendix Table A7
reg std_openness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 5
reg std_openness_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table5.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder

* Table 5
reghdfe std_openness_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Conscientiousness
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A7
reg std_conscientiousness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A7
reg std_conscientiousness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 5
reg std_conscientiousness_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 5
reghdfe std_conscientiousness_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Extraversion
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A7
reg std_extraversion_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A7
reg std_extraversion_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 5
reg std_extraversion_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 5
reghdfe std_extraversion_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Agreeableness
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A7
reg std_agreeableness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A7
reg std_agreeableness_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 5
reg std_agreeableness_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 5
reghdfe std_agreeableness_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Reverse Neuroticism
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A7
reg std_neg_neuroticism_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Appendix Table A7
reg std_neg_neuroticism_index jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

* Table 5
reg std_neg_neuroticism_index jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table5.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder

* Table 5
reghdfe std_neg_neuroticism_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table5.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

** Second stage mediation equation

* Best in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg best_in_third jumpstart gov_kinder too_young_third std_openness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_openness_index jumpstart gov_kinder) replace

reg best_in_third jumpstart gov_kinder too_young_third std_conscientiousness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_conscientiousness_index jumpstart gov_kinder) 

reg best_in_third jumpstart gov_kinder too_young_third std_extraversion_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_extraversion_index jumpstart gov_kinder)

reg best_in_third jumpstart gov_kinder too_young_third std_agreeableness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_agreeableness_index jumpstart gov_kinder)

reg best_in_third jumpstart gov_kinder too_young_third std_neg_neuroticism_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_neg_neuroticism_index jumpstart gov_kinder)

reg best_in_third jumpstart gov_kinder too_young_third std_academic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_academic_index jumpstart gov_kinder)

reg best_in_third jumpstart gov_kinder too_young_third std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_scholastic_index jumpstart gov_kinder)

reg best_in_third jumpstart gov_kinder too_young_third std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA12.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

reghdfe best_in_third std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA12.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_openness_index std_conscientiousness_index std_extraversion_index ///
std_agreeableness_index std_neg_neuroticism_index std_academic_index std_scholastic_index ///
jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) levels(95) scheme(538bw) ///
xtitle(Effect Size) rename (std_openness_index = "Openness index" ///
std_conscientiousness_index = "Conscientiousness index" std_extraversion_index = "Extraversion index" ///
std_agreeableness_index = "Agreeableness index" std_neg_neuroticism_index = "Rev(neuroticism) index" ///
std_academic_index = "Academic expectations index" std_scholastic_index = "Academic skills index" ///
jumpstart = "Jumpstart" gov_kinder = "Gov't kindergarten") title("A: Performed Best in Third Grade")
graph save "mediation_third_big5.gph", replace

* Best in elementary 
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg best_in_elem jumpstart gov_kinder too_young_third std_openness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_openness_index jumpstart gov_kinder) replace

reg best_in_elem jumpstart gov_kinder too_young_third std_conscientiousness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_conscientiousness_index jumpstart gov_kinder) 

reg best_in_elem jumpstart gov_kinder too_young_third std_extraversion_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_extraversion_index jumpstart gov_kinder)

reg best_in_elem jumpstart gov_kinder too_young_third std_agreeableness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_agreeableness_index jumpstart gov_kinder)

reg best_in_elem jumpstart gov_kinder too_young_third std_neg_neuroticism_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_neg_neuroticism_index jumpstart gov_kinder)

reg best_in_elem jumpstart gov_kinder too_young_third std_academic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_academic_index jumpstart gov_kinder)

reg best_in_elem jumpstart gov_kinder too_young_third std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_scholastic_index jumpstart gov_kinder)

reg best_in_elem jumpstart gov_kinder too_young_third std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA13.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

reghdfe best_in_elem std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA13.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_openness_index std_conscientiousness_index std_extraversion_index ///
std_agreeableness_index std_neg_neuroticism_index std_academic_index std_scholastic_index ///
jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) levels(95) scheme(538bw) ///
xtitle(Effect Size) rename (std_openness_index = "Openness index" ///
std_conscientiousness_index = "Conscientiousness index" std_extraversion_index = "Extraversion index" ///
std_agreeableness_index = "Agreeableness index" std_neg_neuroticism_index = "Rev(neuroticism) index" ///
std_academic_index = "Academic expectations index" std_scholastic_index = "Academic skills index" ///
jumpstart = "Jumpstart" gov_kinder = "Gov't kindergarten") title("B: Performed Best in Elementary")
graph save "mediation_elem_big5.gph", replace

* Child enrolled
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_openness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_openness_index jumpstart gov_kinder) replace

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_conscientiousness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_conscientiousness_index jumpstart gov_kinder) 

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_extraversion_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_extraversion_index jumpstart gov_kinder)

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_agreeableness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_agreeableness_index jumpstart gov_kinder)

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_neg_neuroticism_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_neg_neuroticism_index jumpstart gov_kinder)

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_academic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_academic_index jumpstart gov_kinder)

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_scholastic_index jumpstart gov_kinder)

reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA15.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

reghdfe child_enroll std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_enroll too_old_enroll `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA15.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_openness_index std_conscientiousness_index std_extraversion_index ///
std_agreeableness_index std_neg_neuroticism_index std_academic_index std_scholastic_index ///
jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) levels(95) scheme(538bw) ///
xtitle(Effect Size) rename (std_openness_index = "Openness index" ///
std_conscientiousness_index = "Conscientiousness index" std_extraversion_index = "Extraversion index" ///
std_agreeableness_index = "Agreeableness index" std_neg_neuroticism_index = "Rev(neuroticism) index" ///
std_academic_index = "Academic expectations index" std_scholastic_index = "Academic skills index" ///
jumpstart = "Jumpstart" gov_kinder = "Gov't kindergarten") title("D: Currently Enrolled")
graph save "mediation_enrolled_big5.gph", replace

* Placed in top section in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"

reg Section1_full jumpstart gov_kinder too_young_third std_openness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_openness_index jumpstart gov_kinder) replace

reg Section1_full jumpstart gov_kinder too_young_third std_conscientiousness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_conscientiousness_index jumpstart gov_kinder) 

reg Section1_full jumpstart gov_kinder too_young_third std_extraversion_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_extraversion_index jumpstart gov_kinder)

reg Section1_full jumpstart gov_kinder too_young_third std_agreeableness_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_agreeableness_index jumpstart gov_kinder)

reg Section1_full jumpstart gov_kinder too_young_third std_neg_neuroticism_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_neg_neuroticism_index jumpstart gov_kinder)

reg Section1_full jumpstart gov_kinder too_young_third std_academic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_academic_index jumpstart gov_kinder)

reg Section1_full jumpstart gov_kinder too_young_third std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_scholastic_index jumpstart gov_kinder)

reg Section1_full jumpstart gov_kinder too_young_third std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index `child_controls' i.hhid_numeric, cluster(village_id)
outreg2 using TableA14.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

reghdfe Section1_full std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst 
outreg2 using TableA14.tex, keep (std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index jumpstart gov_kinder)

coefplot, keep(std_openness_index std_conscientiousness_index std_extraversion_index ///
std_agreeableness_index std_neg_neuroticism_index std_academic_index std_scholastic_index ///
jumpstart gov_kinder) xline(0) msymbol(d) mfcolor(white) levels(95) scheme(538bw) ///
xtitle(Effect Size) rename (std_openness_index = "Openness index" ///
std_conscientiousness_index = "Conscientiousness index" std_extraversion_index = "Extraversion index" ///
std_agreeableness_index = "Agreeableness index" std_neg_neuroticism_index = "Rev(neuroticism) index" ///
std_academic_index = "Academic expectations index" std_scholastic_index = "Academic skills index" ///
jumpstart = "Jumpstart" gov_kinder = "Gov't kindergarten") title("C: Placed in Top Third Grade Section")
graph save "mediation_topsec_big5.gph", replace

gr combine mediation_third_big5.gph mediation_elem_big5.gph mediation_topsec_big5.gph ///
mediation_enrolled_big5.gph, scheme(538bw) xcommon 

*** Oster's coefficient stability tests

* Note: Set R_max equal to 1.3 times R in "long" regression

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
reg best_in_third jumpstart gov_kinder std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_third `child_controls' i.hhid_numeric, cluster(village_id)

psacalc delta std_conscientiousness_index, mcontrol(jumpstart gov_kinder) rmax(0.337)

reg best_in_third std_conscientiousness_index jumpstart gov_kinder, cluster(village_id)

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
reg Section1_full jumpstart gov_kinder std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_third `child_controls' i.hhid_numeric, cluster(village_id)

psacalc delta std_openness_index, mcontrol(jumpstart gov_kinder) rmax(0.842)

reg Section1_full std_openness_index jumpstart gov_kinder, cluster(village_id)

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
reg child_enroll jumpstart gov_kinder std_openness_index std_conscientiousness_index ///
std_extraversion_index std_agreeableness_index std_neg_neuroticism_index std_academic_index ///
std_scholastic_index too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, cluster(village_id)

psacalc delta std_conscientiousness_index, mcontrol(jumpstart gov_kinder) rmax(.879)

reg child_enroll std_conscientiousness_index jumpstart gov_kinder, cluster(village_id)



